<!--
 * @Author: levi7754 levi7754@163.com
 * @Date: 2025-05-13 15:17:32
 * @LastEditors: levi7754 levi7754@163.com
 * @LastEditTime: 2025-10-13 10:09:43
 * @FilePath: \ruoyi-mall-uniapp\src\pages\workbench\components\select-customer.vue
 * @Description: 客户选择弹框
-->
<template>
  
  <s-layout :title="$t('tabbar.contact')" navbar="custom">
    <ut-indexed
      v-if="dataList?.length"
      :data="dataList"
      :keywords="['customer_name', 'customer_phone', 'phone']"
      :swiper-enable="false"
      show-right-button
      nameField="customer_name"
      background-color="#EA0D2C"
    >	
      <template #content="{data}">
        <view class="ut-contact-item" @tap="onItemTap(data)">
          <view class="ut-item-pic" style="padding-right: 12rpx;">
            <!-- <uni-icons custom-prefix="ucon" :type="`ucon-mine`" size="36" color="#dcdcdc" /> -->
              <image
              class="ut-pic-img"
              :src="udp.$url.cdn(data.store_photo_url || '/static/img/avatar.png')"
              mode="aspectFill"
            />
          </view>
          <view>
            <view style="font-weight: bold;">{{ data.customer_name }}</view>
            <view style="padding: 10rpx 0;">{{ data.customer_phone }}</view>
            <view style="font-size: 12px; color: rgba(0, 0, 0, 0.6);">{{ data.nickName || "Norcal" }}</view>
          </view>
        </view>
      </template>
		</ut-indexed>
  </s-layout>
  <!-- <su-popup :show="show" round="10" :showClose="true" @close="onClose">
    <view class="ss-p-8">
      <uni-easyinput prefixIcon="search" v-model="searchText" :placeholder="$t('placeholder.keywords')" @iconClick="iconClick" />
    </view>
    <uni-list>
      <uni-list-item
        v-for="data in dataList"
        :key="data.id"
        clickable
        @click="onSelect(data)"
      >
        <template #body>
          <view class="ss-p-8">{{ data.customer_name }}</view>
        </template>
      </uni-list-item>
    </uni-list>
  </su-popup> -->
</template>
<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { ref } from "vue"
import { udp } from '@/utils';
import { ajax } from "@/http"

const show = ref(false)
const searchText = ref("")

const dataList = ref([])

const getDataList = (e, idx) => {
  ajax.get("/nature-business/api/customer/page", { currPage: 1, pageSize: 200 }).then(res => {
		const list = res.list
    list.forEach(_ => {
			if (_.store_photo_url) {
				_.store_photo_url = fileUrl + _.store_photo_url
			}
		})
		dataList.value = list
		console.log(dataList.value)
	})
}

const onSelect = (data) => {
  console.log(data)
  emit('select', data)
  show.value = false
}

const onClose = () => {
  console.log('....')
  show.value = false
}

const emit = defineEmits(['close', 'select'])

onLoad(() => {
  show.value = true
  getDataList()
})
</script>